<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('新增审读稿件')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: select2-css"/>
</head>

<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-review-add">

        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">关联样本：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <input type="text" id="sampleid" name="sampleid" class="form-control" placeholder="" readonly required>
                            <span class="input-group-btn">
                            <button type="button" class="btn btn-primary" onclick="selectSample()">关联样本
                            </button>
                            </span>
                        </div>
                        <span class="help-block m-b-none">点击关联按钮</span>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="form-group">
                    <input type="text" readonly id="names" class="form-control" placeholder="" >
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">审读介质：</label>
                    <div id="element" class="col-sm-8 ">
                        <div class="form-row">
                            <div class="form-group col-sm-6">
                                <select name="mediumSuper" class="type form-control " data-first-title="请选择"
                                        required>
                                    <option value="">请选择</option>
                                </select>
                            </div>
                            <div class=" form-group col-sm-6">
                                <select name="mediumSub" class="router form-control " data-first-title="请选择"
                                        required>
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">审读专家：</label>
                    <div class="col-sm-8">
                        <div class="form-row">
                            <div class=" form-group col-sm-5 ">
                                <input type="text" name="expertId" class="form-control" placeholder="" readonly
                                       required>
                                <span class="help-block m-b-none">点击选择按钮</span>
                            </div>
                            <div class=" form-group col-sm-1 ">
                                <span>-</span>
                            </div>
                            <div class="form-group col-sm-6 ">
                                <div class="input-group">
                                    <input type="text" name="expertName" readonly class="form-control" placeholder=""
                                           required>
                                    <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary" onclick="selectExpert()">选择
                                    </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>


        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">提交时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="submitDate" class="form-control" placeholder="yyyy-MM-dd" type="text" autocomplete="off"
                                   required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">题材内容：</label>
                    <div class="col-sm-8">
                        <select name="subjectContent" required class="form-control m-b"
                                th:with="type=${@dict.getType('manuscript_theme')}">
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">稿件形式：</label>
                    <div class="col-sm-8">
                        <select name="form" class="form-control m-b"
                                th:with="type=${@dict.getType('manuscript_form')}" required>
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">稿件倾向：</label>
                    <div class="col-sm-8">
                        <select name="inclination" class="form-control m-b"
                                th:with="type=${@dict.getType('manuscript_tropesis')}" required>
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <!-- <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">采用情况：</label>
                    <div class="col-sm-8">
                        <select name="adoption" class="form-control m-b"
                            th:with="type=${@dict.getType('manuscript_use')}" required>
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">期刊说明：</label>
                    <div class="col-sm-8">
                        <input name="journalDesc" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div> -->

        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">稿件费用：</label>
                    <div class="col-sm-8">
                        <div class="input-group m-b">
                            <span class="input-group-addon">¥</span>
                            <input type="number" name="cost" class="form-control" required>
                            <span class="input-group-addon">元</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <!-- form-group  -->
                <div class="row">
                    <label class="col-sm-4 control-label is-required">采用情况：</label>
                    <div class="col-sm-3">
                        <select name="adoption" class="form-control m-b"
                                th:with="type=${@dict.getType('manuscript_use')}" required>
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                    <label class="col-sm-2 control-label ">期刊/说明：</label>
                    <div class="col-sm-3">
                        <input name="journalDesc" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">备注：</label>
                    <div class="col-sm-8">
                        <input name="remark" class="form-control" type="text">
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <!-- form-group  -->
                <div class="row">
                    <label class="col-sm-4 control-label is-required">稿件来源：</label>
                    <div class="col-sm-3">
                        <select name="source" class="form-control m-b"
                                th:with="type=${@dict.getType('manuscript_source')}" required>
                            <option value="">--请选择--</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                    <label class="col-sm-2 control-label ">说明：</label>
                    <div class="col-sm-3">
                        <input name="reviewDesc" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">稿件名称：</label>
                    <div class="col-sm-4">
                        <input name="reviewName" class="form-control" type="text" required>

                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">稿件内容：</label>
                    <div class="col-sm-10">
                            <textarea name="reviewContent" class="form-control" placeholder="输入稿件内容"
                                      rows="10"></textarea>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">其它说明：</label>
                    <div class="col-sm-10">
                            <textarea name="otherDesc" maxlength="500" class="form-control" placeholder="输入其它说明"
                                      rows="3"></textarea>
                    </div>
                </div>
            </div>
        </div>


        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-2 control-label ">附件：</label>
                <div class="col-sm-10">
                    <!--             type="hidden"  class="myhide"          width设置为0，高度设置为0.5px-->
                    <input name="append"  style="visibility: hidden" readonly>
                    <br/>
                    <div class="file-loading">
                        <input class="form-control file-upload" multiple id="append" name="file" type="file">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i
                        class="fa fa-check"></i>保 存
                </button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                        class="fa fa-reply-all"></i>关 闭
                </button>
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: jquery-cxselect-js"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var prefix = ctx + "publish/review";

    $("#form-review-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.saveTab(prefix + "/add", $('#form-review-add').serialize());
        }
    }

    $("input[name='submitDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    // 上传 name 属性值必须为file
    $(".file-upload").fileinput({
        uploadUrl: '/common/upload',
        showUpload: false,
        showRemove : true,
        maxFileSize: 30000,
        autoReplace: true,
        //allowedFileExtensions: ['jpg', 'png', 'bmp', 'jpeg'],
        showUpload: false, //是否显示上传按钮
        showCaption: true,//是否显示标题
        browseClass: "btn btn-primary",//按钮样式
        dropZoneTitle:"拖拽文件到这里",
        previewFileIcon: '<i class="fa fa-file-o text-info"></i>',
        preferIconicPreview: true,// 是否优先显示图标  false 即优先显示图片
        previewFileIconSettings: {
            'docx': '<i class="fa fa-file-word-o text-primary"></i>',
            'doc': '<i class="fa fa-file-word-o text-primary"></i>',
            'xlsx': '<i class="fa fa-file-excel-o text-success"></i>',
            'xls': '<i class="fa fa-file-excel-o text-success"></i>',
            'pptx': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
            'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
            'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
            'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
            'sql': '<i class="fa fa-file-word-o text-primary"></i>',
            'txt': '<i class="fa fa-file-text-o text-info"></i>',
            'rtf': '<i class="fa fa-file-text-o text-info"></i>',
        },
        // layoutTemplates: {
        //     actionDelete:'', //去除上传预览的缩略图中的删除图标
        //     actionUpload: '',//去除上传预览缩略图中的上传图片图标；
        //     //actionZoom:''   //去除上传预览缩略图中的查看详情预览的缩略图标。
        // },
    }).on('filebatchselected', function (event, data, id, index) {
        $(this).fileinput("upload");
    }).on('fileuploaded', function (event, data, previewId, index) {
        if($("input[name='" + event.currentTarget.id + "']").val()==""){
            $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName);
        }else {
            $("input[name='" + event.currentTarget.id + "']").val($("input[name='" + event.currentTarget.id + "']").val()+','+data.response.fileName);
        }
    }).on('filecleared', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    }).on('filesuccessremove', function (event, id, index) {//删除新上传的文件
        var nu=-1;
        var src = $("#"+id).attr("title");
        var fileUrlList = $("input[name='" + event.currentTarget.id + "']").val().split(",");
        if(src==""||src==null){
            src = $("#"+id+" img").attr("title");
            for(var i = 0 ;i<=fileUrlList.length-1;i++){
                var src1 = fileUrlList[i].substring(fileUrlList[i].lastIndexOf("/")+1);
                if(src1 == src ){
                    nu =i;
                }
            }
        }else{
            for(var i = 0 ;i<=fileUrlList.length-1;i++){
                var title1 = fileUrlList[i].substring(fileUrlList[i].lastIndexOf("/")+1);
                if(title1 == src ){
                    nu =i;
                }
            }
        }
        fileUrlList.splice(nu, 1);//去除下标为nu的值
        $("input[name='" + event.currentTarget.id + "']").val(fileUrlList);
    }).on('filedeleted', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    });


    var mediumdata = [
        {   //新闻报、行业报、区县报、大学报
            "s": [
                {"s": null, "v": "新闻报", "n": "新闻报"},
                {"s": null, "v": "行业报", "n": "行业报"},
                {"s": null, "v": "区县报", "n": "区县报"},
                {"s": null, "v": "大学报", "n": "大学报"},
            ],
            "v": "报纸",
            "n": "报纸"
        },
        {   //公开刊物、连续性内部资料、大学学报
            "s": [
                {"s": null, "v": "公开刊物", "n": "公开刊物"},
                {"s": null, "v": "连续性内部资料", "n": "连续性内部资料"},
                {"s": null, "v": "大学学报", "n": "大学学报"},
            ],
            "v": "期刊",
            "n": "期刊"
        },
        {   //公开发行图书、非连续性内部资料
            "s": [
                {"s": null, "v": "公开发行图书", "n": "公开发行图书"},
                {"s": null, "v": "非连续性内部资料", "n": "非连续性内部资料"},
            ],
            "v": "图书",
            "n": "图书"
        },
        {   // 资讯、小说、游戏
            "s": [
                {"s": null, "v": "资讯", "n": "资讯"},
                {"s": null, "v": "小说", "n": "小说"},
                {"s": null, "v": "游戏", "n": "游戏"},
            ],
            "v": "互联网出版",
            "n": "互联网出版"
        },
        {   //渝版、非渝版
            "s": [
                {"s": null, "v": "渝版", "n": "渝版"},
                {"s": null, "v": "非渝版", "n": "非渝版"},
            ],
            "v": "发行",
            "n": "发行"
        },
        {   //半月刊、月刊、双月刊、季刊
            "s": [
                {"s": null, "v": "电子", "n": "电子"},
                {"s": null, "v": "音像", "n": "音像"},
            ],
            "v": "电子音像",
            "n": "电子音像"
        }
    ];
    $('#element').cxSelect({
        selects: ['type', 'router'],
        jsonValue: 'v',
        data: mediumdata
    });

    function selectExpert() {
        $.modal.open("选择专家", ctx + "publish/managementt/expertSelect");
    }
    function selectSample() {
        $.modal.open("关联样本", ctx + "publish/sample/sampleSelect",1200);
    }
    // 设置专家
    function setExpert(ids, names) {
        // debugger
        $("input[name='expertId']").val(ids);
        $("input[name='expertName']").val(names);
    }

    // 设置样本
    function setSample(rows){
        var _ids=[];
        var _names=[];
        rows.forEach(function(item){
            _ids.push(item.id);
            _names.push(item.name);
        })
        $('#sampleid').val(_ids.join(','));
        $('#names').val(_names.join(','));
    }



</script>
</body>

</html>